package com.binarytree;

import java.util.Map;

public class Solution24 {
    int res = Integer.MAX_VALUE;
    TreeNode pre;
    public int getMinimumDifference(TreeNode root) {
        getMin(root);
        return res;
    }

    public void getMin(TreeNode root) {
        if (root == null) return;
        getMin(root.left);
        if (pre != null) {
            res = Math.min(res,root.val-pre.val);
        }
        pre = root;
        getMin(root.right);
    }
}
